import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { SharedModule } from 'src/app/shared/shared.module';
import { AclGuard } from 'src/app/core/guard/acl.guard';
import { ROLE_LIST } from 'src/app/core/auth/role';

import { PlatformComponent } from './pages/platform.component';

// 超级管理员：企业用户
import { OrgUsersComponent } from './pages/super-admin/org-users.component';
// 企业管理员：小组用户 和 普通用户
import { GroupUsersComponent } from './pages/org-admin/group-users/group-users.component';
import { UsersComponent } from './pages/org-admin/users/users.component';
// 小组管理员：普通用户
import { CommonUsersComponent } from './pages/group-admin/common-users/common-users.component';
// 各种弹框
import { AddUserModalComponent } from './pages/group-admin/add-user-modal/add-user-modal.component';
import { AddGroupUserComponent } from './pages/org-admin/group-users/add-group-user/add-group-user.component';
import { AddOrgUserComponent } from './pages/super-admin/add-org-user/add-org-user.component';
import { EditGroupUserComponent } from './pages/org-admin/group-users/edit-group-user/edit-group-user.component';
import { EditOrgUserComponent } from './pages/super-admin/edit-org-user/edit-org-user.component';
import { EditAdminUserComponent } from './pages/super-admin/edit-admin-user/edit-admin-user.component';
import { EditUserComponent } from './pages/group-admin/edit-user/edit-user.component';
import { AddUserComponent } from './pages/org-admin/users/add-user/add-user.component';
import { OrgEditUserComponent } from './pages/org-admin/users/org-edit-user/org-edit-user.component';

// 路由配置
const routes: Routes = [
  {
    // 一级路由
    path: '', component: PlatformComponent,
    // 二级路由
    children: [
      { path: '', loadChildren: './pages/data-center/data-center.module#DataCenterModule' },
      { path: 'data-center', loadChildren: './pages/data-center/data-center.module#DataCenterModule' },
      // 超级管理员：企业用户
      { path: 'org-users', component: OrgUsersComponent },
      // 企业管理员：小组用户 和 普通用户
      {
        path: 'group-users', component: GroupUsersComponent,
        /* data: { roles: [...ROLE_LIST.allManage] },
        canActivate: [AclGuard] */
      },
      {
        path: 'users', component: UsersComponent,
        /* data: { roles: [...ROLE_LIST.allManage] },
        /* canActivate: [AclGuard] */
      },
      // 小组管理员：普通用户
      {
        path: 'common-users', component: CommonUsersComponent,
        /* data: { roles: [...ROLE_LIST.allManage] },
        canActivate: [AclGuard] */
      },
    ]
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes), SharedModule],
  declarations: [
    PlatformComponent,
    OrgUsersComponent,
    UsersComponent,
    GroupUsersComponent,
    CommonUsersComponent,
    AddUserModalComponent,
    AddGroupUserComponent,
    AddOrgUserComponent,
    EditGroupUserComponent,
    EditOrgUserComponent,
    EditAdminUserComponent,
    EditUserComponent,
    AddUserComponent,
    OrgEditUserComponent
  ],
  entryComponents: [
    AddUserModalComponent,
    AddGroupUserComponent,
    AddOrgUserComponent,
    EditGroupUserComponent,
    EditAdminUserComponent,
    EditOrgUserComponent,
    EditUserComponent,
    OrgEditUserComponent,
    AddUserComponent
  ],
})
export class PlatformModule { }
